<div data-am-widget="titlebar" class="am-titlebar am-titlebar-column2" style="height:25px;line-height:25px;font-size:12px;margin-top:50px;">
    <div class="am-titlebar-left">评论</div>
    <div class="am-titlebar-right">最新 </div><br />           
</div>

<ul class="am-comment-list">
    <loop table="discuss" pid="$body['id']" module="$type['module']" limit="10" page="$pagedis">
                <li class="am-comment">
                    <a href="#link-to-user-home">
                        <img <if condition="$v['user']['pic']"> src="{$v['user']['pic']}" <else/>src="__PUBLIC__/gust.png"</if> alt="" class="am-comment-avatar" width="48" height="48"/>
                    </a>             
                    <div class="am-comment-main">
                        <header class="am-comment-hd">
                                          <!--<h3 class="am-comment-title">评论标题</h3>-->
                            <div class="am-comment-meta">
                                <a href="#link-to-user" class="am-comment-author">
                                    <if condition="$v['user']">
                                    {$v['user']['username']}：
                                    <else/>
                                        游客：
                                    </if>
                                </a>
                                评论于 <time >{$v['cdate']|date='Y-m-d H:m:s',###}</time>
                            </div>
                        </header>       
                        <div class="am-comment-bd">
                            {$v['body']}
                            <br /><br />
                            <a class="am-badge am-badge-success">回复</a>
                            <a class="am-badge am-badge-success">顶一下</a>
                        </div>
                    </div>
                </li>
    </loop>
</ul>
<div class="am-cf">  <div class="am-pagination  am-fr">{$pagedis}</div></div>

<div class="am-comment am-comment-flip am-comment-highlight">
                    <a href="#link-to-user-home">
                        <img src="__PUBLIC__/pinglun.png" alt="" class="am-comment-avatar" width="48" height="48"/>
                    </a>             
                    <div class="am-comment-main">
                        <header class="am-comment-hd">
                         
                            <div class="am-comment-meta">
                                我来评论：
                            </div>
                        </header>       
                        <textarea class="am-comment-bd pinglun" style="width: 100%;border:0px;" contentEditable=true></textarea>
                    </div>
</div>
 <button onclick="subimt()" type="button" class="am-btn am-btn-default" style="height:30px;line-height:30px;padding:0px 10px;margin:10px 0px;font-size:13px;">提交评论</button>

<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">提示：
      <a href="" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
      请发表有效评论并且内容要大于5个字符。
    </div>
  </div>
</div>
<script>
function subimt(){
    var pphtml=$('.pinglun').val();
    var reg=new RegExp(" ","g");
    pphtml=pphtml.replace(reg,"");
    if(pphtml.length<5){
        $('#doc-modal-1').modal('toggle');
        return;
    }
    var chtml=$('.pinglun').val();
    var url="{:U('Discuss/submit_e',array('pid'=>$body['id'],'tag'=>$type['module']))}";
    $.ajax({type:'post',url:url,data:{body:$('.pinglun').val()},success:function(data){
        if(data.status==0){
            var d=new Date();
            var hdata=$('.pinglun').val();
            var username='游客';
            if(data.data!=null) username=data.data;
            var pic='{:session("muser.pic")}';
            if(!pic) pic="__PUBLIC__/gust.png";
            var shtml='<li class="am-comment"><a href="#link-to-user-home"><img src="'+pic+'" alt="" class="am-comment-avatar" width="48" height="48"/></a><div class="am-comment-main"><header class="am-comment-hd"><div class="am-comment-meta"><a href="#link-to-user" class="am-comment-author">'+username+'：</a>评论于 <time >'+d+'</time></div></header><div class="am-comment-bd">'+hdata+'<br/><br/><a class="am-badge am-badge-success">回复</a> <a class="am-badge am-badge-success">顶一下</a></div></div></li>';
            $('.am-comment-list').prepend(shtml);
        }
        else{
            alert(data.info);
        }
	}})
}
</script>